package com.rivulet.doj_backend.mapper;

import com.rivulet.doj_backend.pojo.Question;
import com.rivulet.doj_backend.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

@Component
public interface QuestionMapper {
    @Select("select * from t_question where question_id = #{question_id}")
    public Question getQuestionByQuestionId(@Param("question_id") Integer question_id);

    @Select("select * from t_question limit #{page*25},25")
    public Question showQuestion(@Param("page") Integer page);

    @Insert("insert into t_question (question_id,question_title,question_content,diffculty) values (#{user_id},#{question_title},#{question_content},#{diffculty})")
    public void addQuestion(@Param("question_id") Integer question_id, @Param("question_title") String question_title, @Param("question_content") String question_content, @Param("diffculty") Integer diffculty);

    @Insert("insert into r_question_label (questuion_id,label_id) values (#{user_id},#{label_id})")
    public void addLabelId(@Param("question_id") Integer question_id, @Param("label_id") Integer label_id);

    @Insert("insert into r_user_collect_question (user_id,question_id) values (#{user_id},#{question_id})")
    public void addUserCollectQuestion(@Param("user_id") Integer user_id, @Param("question_id") Integer question_id);

}
